package array;
/*
        查;
        查元素:数组名[索引]
                ->int[] arr = new int[3];
                                arr[0],arr[1],arr[2]
        查元素个数.数组长度的:数组名 length //length属性
 */

public class ArrayDemo1 {
    int num;//成员变量

    public static void main(String[] args) {//成员方法:所有的方法都是成员方法
        //动态初始化
        //栈中 接收地址 指向堆中
        int[] arr1 = new int[3];
        System.out.println("arr1 = " + arr1);//这里输出的是地址值
        //查元素
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr1[i]= " + arr1[i]);

        }
        System.out.println("arr1.length = " + arr1.length);//3

        System.out.println("=========================");


        //修改arr1[1] arr数组的第二个元素
        arr1[1] = 100;
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr1[i] = " + arr1[i]);

        }


        //静态初始化
        int[] arr2 = {5, 6, 7, 8};
        System.out.println("arr2 = " + arr2);//地址值
        System.out.println("=========================");

        //修复元素
        arr2[3] = 111;
        arr2[0] = 222;


        //查元素
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr2[i] = " + arr2[i]);

        }
        System.out.println("arr2.length = " + arr2.length);//4
        System.out.println("=========================");


    }
}
